home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / programming / arexx / rexxbgui / selectline.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-05-14  |  1.8 KB  |  84 lines

  1. /* REXX */
  2. /* REXX script for rexxbgui.library */
  3.  
  4. if ~show('l','rexxbgui.library') then do
  5.     if ~addlib('rexxbgui.library',0,-30) then do
  6.         exit(20)
  7.     end
  8.     else nop
  9. end
  10. else nop
  11.  
  12. call bguiopen() /* causes error 12 if it did not work */
  13. /* supply a second argument for a '0' return code instead of an ARexx
  14.    error */
  15.  
  16. fname=arg(1)
  17. if bguireadentries(fname,'LST')~=1 then bguierror(12)
  18.  
  19. signal on syntax /* important: bguiclose() MUST be called */
  20. signal on halt
  21. signal on break_c
  22.  
  23. esc='1B'x
  24. lf='0A'x
  25. cr='0D'x
  26. grspace.narrow=-1
  27. grspace.normal=-2
  28. grspace.wide=-3
  29.  
  30. /* using ARexx feature: ,<newline> is translated to nothing */
  31. /* the || are essential - any added space will cause trouble */
  32. /* redefining the same ID makes previous buttons unaccessible */
  33. /* do not redefine winclose etc. */
  34.  
  35. g=bguivgroup(,
  36.     bguivgroup(,
  37.         bguilistview('sslistv',,'LST','S')||,
  38.         bguistring('str',,,256)||bguilayout(LGO_FixMinHeight,1)||,
  39.     '',0)||,
  40.     bguihgroup(,
  41.         bguivarspace(50)||,
  42.         bguibutton('quit','_Quit')||,
  43.         bguivarspace(50),
  44.     )||bguilayout(LGO_FixMinHeight,1),
  45. ,grspace.normal,grspace.normal)
  46.  
  47. call bguiaddmap(obj.sslistv,obj.str,LISTV_Entry,STRINGA_TextVal)
  48.  
  49. a=bguiwindow(fname,g,50,30)
  50.  
  51. call bguiset(obj.sslistv,,BT_RawKey,80) /* F1 */
  52. call bguiset(obj.str,,BT_RawKey,81) /* F2 */
  53.  
  54. if bguiwinopen(a)=0 then bguierror(12) else nop
  55.  
  56. call bguiactivategadget(obj.str,a)
  57.  
  58. id=0
  59. do while bguiwinwaitevent(a,'ID')~=id.winclose
  60.     select
  61.         when id=id.winactive then nop
  62.         when id=id.wininactive then nop
  63.         when id=id.quit then leave
  64.         when id=id.winclose then nop
  65.         otherwise nop
  66.     end
  67. end
  68. res=bguiget(obj.str,STRINGA_TextVal)
  69. call bguiclose()
  70. parse source bla1 reswanted .
  71. if reswanted then return res; else exit 0
  72.  
  73. syntax:
  74. if rc~=0 then say '+++ ['rc']' errortext(rc) 'at line' sigl else nop
  75. call bguiclose()
  76. exit 10
  77.  
  78. break_c:
  79. halt:
  80. rc=0
  81. say '+++ Break at line' sigl
  82. call bguiclose()
  83. exit 10
  84.